#ifndef PARAMCHOOSEDIALOG_H
#define PARAMCHOOSEDIALOG_H

#include <QLabel>
#include <QDialog>
#include <QLineEdit>
#include <QComboBox>
#include <QBoxLayout>
#include <QTextStream>
#include <QFileDialog>
#include <QMessageBox>
#include <QListWidget>
#include <QPushButton>
#include <QRadioButton>

#include "defs.h"
#include "taskType.h"
#include "spredsheet.h"

const int dlgNumber = 2;

class inputParamWidget : public QWidget
{
    Q_OBJECT
public:
    QVBoxLayout *mainLayout;
    QHBoxLayout *inputFileLayout;
    QHBoxLayout *nmParamLayout;
    QRadioButton *fromFileRadio;
    QRadioButton *manualRadio;
    QPushButton *inputBrowsePush;
    QPushButton *editManualPush;
    QLineEdit *inputFileEdit;
    QLineEdit *detailsEdit;
    QLineEdit *machinesEdit;
    QLineEdit *taskNameEdit;
    QLabel *detailsLabel;
    QLabel *machinesLabel;
    QLabel *taskNameLabel;

public:
    inputParamWidget( QWidget *parent = 0 );
};

class paramWidget : public QWidget
{
    Q_OBJECT
public:
    QVBoxLayout *mainLayout;
    QLabel *algoLabel;
    QLabel *optLabel;
    QComboBox *algoBox;
    QComboBox *optBox;

    paramWidget( QWidget *parent = 0 );
};

class paramChooseDialog : public QDialog
{
    Q_OBJECT
private:
    int state;

    bool manualInputChoosen;
    bool fileInputChoosen;

    QString inputFileName;
    QVector<QVector<int> > inputTable;

    inputParamWidget* inputParam;
    paramWidget*      param;
    spredsheet*       sheet;

    taskType task;

    QListWidget *stepList;

    QPushButton *backButton;
    QPushButton *nextButton;
    QPushButton *closeButton;

    QVBoxLayout *mainLayout;
    QHBoxLayout *infoLayout;
    QVBoxLayout *paramLayout;
    QHBoxLayout *buttonsLayout;

    QLabel *captionLable;

    void createMainLayout();

    void updateDialog();
    void setTask(taskType task);

private slots:
    void nextParamDlg();
    void prevParamDlg();

    void browseInputFile();
    void manualEditInput();

    void clearDialog();             //clears Line edits & all bool paramets are set to default
    void tableMade( QVector<QVector<int> > inputTable );

public:
    paramChooseDialog( QWidget *parent = 0 );
    void setReason( int reason, taskType item ); //edit or new

signals:
    void itemMade( taskType );
};

#endif // PARAMCHOOSEDIALOG_H
